package com.yuelao.java8;

import java.util.Optional;

/**
 * Created by fengliye on 2017/10/7.
 */
public class OptionalTest {
    public static void main(String[] args) {
        // of方法不可以传null
        Optional<String> optional = Optional.of("feng");
        // ofNullable可以为null
        Optional<String> optional1 = Optional.ofNullable(null);
        // 是否存在值
        boolean e = optional.isPresent();
        String value = optional.get();
    }
}